<?php

namespace app\admin\controller;

use app\common\controller\AdminBaseController;

class LinksController extends AdminBaseController
{
    protected function initialize()
    {
        parent::initialize();
        $this->server = model('server.links');
    }

    public function getLinksListPageOp()
    {
        $requestData = validateRequestParam('links', 'getListPage');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('GET_SUCCESS')];
        $responseData['data'] = $this->server->getListPage($requestData);

        return $responseData;
    }

    public function saveLinksAddOp()
    {
        $requestData = validateRequestParam('links', 'saveAdd');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('SAVE_SUCCESS')];
        $responseData['data'] = $this->server->saveAdd($requestData);

        return $responseData;
    }

    public function getLinksRowOp()
    {
        $requestData = validateRequestParam('links', 'getRow');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('GET_SUCCESS')];
        $responseData['data'] = $this->server->getRow($requestData);

        return $responseData;
    }

    public function saveLinksEditOp()
    {
        $requestData = validateRequestParam('links', 'saveEdit');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('SAVE_SUCCESS')];
        $responseData['data'] = $this->server->saveEdit($requestData);

        return $responseData;
    }

    public function saveLinksDelOp()
    {
        $requestData = validateRequestParam('links', 'saveEdit');
        $responseData['meta'] = ['code' => 1, 'msg' => lang('DEL_SUCCESS')];
        $responseData['data'] = $this->server->saveDel($requestData);

        return $responseData;
    }
}
